Skip to content

[AspNetCore] Update gRPC Semantic Conventions#4370

Open
martincostello wants to merge 9 commits into
open-telemetry:mainfrom
martincostello:update-aspnetcore-grpc-semantic-conventions
Open

[AspNetCore] Update gRPC Semantic Conventions#4370
martincostello wants to merge 9 commits into
open-telemetry:mainfrom
martincostello:update-aspnetcore-grpc-semantic-conventions

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented May 7, 2026

Changes

Update the Semantic Conventions version for gRPC Server spans to v1.41.0.

One thing I'm unsure of is whether or not we need to implement OTEL_SEMCONV_STABILITY_OPT_IN or not given that the support is already experimental.

Once that question is answered I'll add/update the tests as appropriate.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Add optimizations, recommended by Copilot, to reduce allocations in `HttpInListener.OnStopActivity()`:

- Cache activity display names.
- Uses slices instead of `Regex`.
- Avoid enum reflection.
- Null check delegates to avoid try-catch blocks.
- Use SetCustomProperty to check for who made the instrumentation.
- Avoid running gRPC-related code for HTTP 1.1.
- Avoid additional check for the normalized HTTP method.
- Use pattern matching on nullable.
Update the Semantic Conventions version for RPC Server spans to v1.41.0.
@github-actions github-actions Bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label May 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 83.87097% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.01%. Comparing base (99e5887) to head (c23ae0e).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tation.AspNetCore/Implementation/HttpInListener.cs 80.76% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4370      +/-   ##
==========================================
- Coverage   76.09%   76.01%   -0.09%     
==========================================
  Files         455      455              
  Lines       18334    18358      +24     
==========================================
+ Hits        13952    13955       +3     
- Misses       4382     4403      +21     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 89.95% <ø> (ø)
unittests-Exporter.Geneva 54.82% <ø> (-0.27%) ⬇️
unittests-Exporter.InfluxDB 95.81% <ø> (ø)
unittests-Exporter.OneCollector 94.63% <ø> (ø)
unittests-Extensions 90.78% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 85.22% <ø> (ø)
unittests-Instrumentation.AspNet 78.04% <ø> (ø)
unittests-Instrumentation.AspNetCore 87.19% <83.87%> (-0.57%) ⬇️
unittests-Instrumentation.Cassandra 92.85% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 78.52% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.60% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 81.39% <ø> (ø)
unittests-Instrumentation.EventCounters 77.67% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.34% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 79.09% <ø> (ø)
unittests-Instrumentation.Hangfire 88.91% <ø> (ø)
unittests-Instrumentation.Http 75.24% <ø> (ø)
unittests-Instrumentation.Owin 89.22% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Remoting 66.06% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 40.83% <ø> (ø)
unittests-Instrumentation.SqlClient 82.86% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 93.84% <ø> (ø)
unittests-Instrumentation.Wcf 82.60% <ø> (ø)
unittests-OpAmp.Client 84.83% <ø> (-0.20%) ⬇️
unittests-PersistentStorage 69.29% <ø> (ø)
unittests-Resources.AWS 74.49% <ø> (ø)
unittests-Resources.Azure 88.31% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 72.26% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 90.47% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 96.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...spNetCore/AspNetCoreTraceInstrumentationOptions.cs 96.42% <100.00%> (+0.77%) ⬆️
src/Shared/GrpcTagHelper.cs 98.07% <ø> (ø)
...tation.AspNetCore/Implementation/HttpInListener.cs 86.06% <80.76%> (-1.30%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Also remove `grpc.status` and `grpc.target`.
@martincostello martincostello added the keep-open Prevents issues and pull requests being closed as stale label May 8, 2026
Move RpcSemanticConventionHelper to shared code for re-use.
@martincostello martincostello marked this pull request as ready for review May 19, 2026 15:28
@martincostello martincostello requested a review from a team as a code owner May 19, 2026 15:28
Copilot AI review requested due to automatic review settings May 19, 2026 15:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ASP.NET Core gRPC server-span attribute emission to support newer RPC/gRPC semantic conventions (v1.41.0) behind the OTEL_SEMCONV_STABILITY_OPT_IN opt-in mechanism, while preserving the existing default behavior.

Changes:

  • Introduces RpcSemanticConventionHelper to parse OTEL_SEMCONV_STABILITY_OPT_IN and select old/new/dual RPC attribute emission.
  • Updates ASP.NET Core gRPC server span tagging to optionally emit v1.41.0-style RPC attributes and remove additional gRPC framework tags.
  • Updates docs/changelog/solution/project wiring to include the new helper and reference updated spec links.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Shared/RpcSemanticConventionHelper.cs Adds opt-in parsing for RPC semantic convention emission modes (rpc, rpc/dup).
src/Shared/GrpcTagHelper.cs Adds additional gRPC tag constants and updates spec link references.
src/OpenTelemetry.Instrumentation.AspNetCore/README.md Updates the semantic conventions documentation link target.
src/OpenTelemetry.Instrumentation.AspNetCore/OpenTelemetry.Instrumentation.AspNetCore.csproj Links in the new shared RPC semantic convention helper file.
src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Gates gRPC server-span tag emission between old/new conventions and removes more framework-provided gRPC tags.
src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md Documents the new opt-in behavior for RPC/gRPC semconv v1.41.0.
src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs Adds options derived from OTEL_SEMCONV_STABILITY_OPT_IN to control old/new RPC tag emission.
opentelemetry-dotnet-contrib.slnx Adds the new shared helper file to the solution.
Comments suppressed due to low confidence (1)

src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs:456

  • When emitting the new RPC semantic conventions, rpc.service is intentionally omitted, but rpc.method is still set to only the method name (details.RpcMethod). This loses the service portion and doesn’t align with the v1.40+ guidance that rpc.method should be the fully-qualified logical method name. Consider setting rpc.method to the fully-qualified value (e.g., the same value used for activity.DisplayName) when emitNewRpcAttributes is enabled.
            activity.SetTag(SemanticConventions.AttributeRpcMethod, details.RpcMethod);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs Outdated
Comment thread src/Shared/RpcSemanticConventionHelper.cs
Use correct properties to populate `network.peer.address` and `network.peer.port`.
The GitHub UI didn't actually apply the changes I made to fix it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore keep-open Prevents issues and pull requests being closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants